package com.antony.message0927;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Message {
	InputStream in;
	OutputStream out;
	BufferedReader bs;

	public void recive() {
		try {
			ServerSocket sever = new ServerSocket(6666);
			while (true) {
				Socket sk = sever.accept();
				in = sk.getInputStream();
				String wel = "welcome!\n\t";
				out = sk.getOutputStream();
				out.write(wel.getBytes());
				while (true) {
					bs = new BufferedReader(new InputStreamReader(in));
					out.write(("You said:" + bs.readLine() + "\n\t").getBytes());
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
